package com.example.figurehecheng.controller.merchant;


import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.dto.NewsDTO;
import com.example.figurehecheng.domain.dto.SceneryCreateDTO;
import com.example.figurehecheng.domain.entity.News;
import com.example.figurehecheng.domain.vo.NewsVO;
import com.example.figurehecheng.domain.vo.SceneryVO;
import com.example.figurehecheng.service.INewsService;
import com.example.figurehecheng.service.ISceneryService;
import com.example.figurehecheng.service.impl.NewsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 新闻资讯表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-04
 */
@RestController("adminNewsController")
@RequestMapping("/admin/news")
@CrossOrigin
@RequiredArgsConstructor
public class NewsController {

    @Autowired
    private INewsService newsService;

    @ApiOperation("获取咨询列表")
    @GetMapping("/list")
    public Result<List<NewsVO>> getConsultationList() {
        List<NewsVO> list = newsService.getNewsList();
        return Result.success(list);
    }

    @ApiOperation("获取咨询详情")
    @GetMapping("/detail/{id}")
    public Result<NewsVO> getConsultationDetail(@PathVariable Long id) {
        NewsVO detail = newsService.getNewsDetail(id);
        return Result.success(detail);
    }

//        @ApiOperation("回复咨询")
//        @PostMapping("/reply")
//        public Result<Boolean> replyConsultation(@RequestBody NewsDTO dto) {
//            boolean success = newsService.replyNews(dto.getId(), dto.getReply());
//            return Result.success(success);
//        }

    @ApiOperation("删除咨询")
    @DeleteMapping("/delete/{id}")
    public Result<Boolean> deleteConsultation(@PathVariable Long id) {
        boolean success = newsService.deleteNews(id);
        return Result.success(success);
    }

    @PostMapping("/create")
    @ApiOperation("创建咨询")
    public Integer createScenery(@RequestBody @Valid NewsDTO dto) {
        System.out.println(dto);
        Integer i = newsService.create(dto);
        return i;
    }
}

